package com.qiwx.pigeon.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.qiwx.pigeon.R;
import com.qiwx.pigeon.data.vo.CageRepairBean;

import androidx.annotation.Nullable;
import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @description
 * @Author qiwx
 * @Date 2020-06-10 17:25
 * 鸽笼淘汰
 **/
public class EliminateOptionView extends LinearLayout {
    @BindView(R.id.group_cage_status_death_options)
    RadioGroup group_cage_status_death_options;
    @BindView(R.id.rb_cage_status_death_1)
    RadioButton rb_cage_status_death_1;
    @BindView(R.id.rb_cage_status_death_2)
    RadioButton rb_cage_status_death_2;

    @BindView(R.id.group_eliminate_options)
    RadioGroup group_eliminate_options;
    @BindView(R.id.rb_cage_eliminate_1)
    RadioButton rb_cage_eliminate_1;
    @BindView(R.id.rb_cage_eliminate_2)
    RadioButton rb_cage_eliminate_2;

    @BindView(R.id.layout_eliminate)
    LinearLayout layout_eliminate;


    public EliminateOptionView(Context context) {
        this(context, null);
    }

    public EliminateOptionView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public EliminateOptionView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
        initEvent();
    }

    private void initView(Context context) {
        LayoutInflater mInflater = LayoutInflater.from(context);
        View view = mInflater.inflate(R.layout.cage_eliminate_option, null);
        ButterKnife.bind(this, view);
        addView(view);

    }


    public CageRepairBean getParam() {
        CageRepairBean param = new CageRepairBean();
        return param;

    }


    //重置选项
    public void initEvent() {

        rb_cage_status_death_1.setChecked(true);
        rb_cage_status_death_1.setOnCheckedChangeListener((bt, ischeck) -> {
            if (ischeck) {
                layout_eliminate.setVisibility(VISIBLE);
            }
        });
        rb_cage_status_death_2.setOnCheckedChangeListener((bt, ischeck) -> {
            if (ischeck) {
                layout_eliminate.setVisibility(GONE);
            }
        });

    }
}
